import tkinter as tk
import tkinter.messagebox as mb


	
top = tk.Tk()
top.title('选择题')
def q1():
	l1 = tk.Label(
		top,
		text='蜜雪冰城第一句是？',
		font=('Arial', 12),
		width=30,
		height=2
	)
	l1.pack()
	v1 = tk.IntVar()
	v1.set(-1)
	a1 = tk.Radiobutton(top, text='你爱我', variable=v1, value=25)
	a1.pack()
	b1 = tk.Radiobutton(top, text='我爱你', variable=v1, value=0)
	b1.pack()
	return v1.get()

def q2():
	l2 = tk.Label(
		top,
		text='"首孝悌，次谨信。"出自？',
		font=('Arial', 12),
		width=30,
		height=2
	)
	l2.pack()
	v2 = tk.IntVar()
	v2.set(-1)
	a2 = tk.Radiobutton(top, text='三字经', variable=v2, value=0)
	a2.pack()
	b2 = tk.Radiobutton(top, text='弟子规', variable=v2, value=25)
	b2.pack()
	return v2

def q3():
	l3 = tk.Label(
		top,
		text='您喜欢喝？',
		font=('Arial', 12),
		width=30,
		height=2
	)
	l3.pack()
	ab1 = tk.BooleanVar()
	bb1 = tk.BooleanVar()
	ab1.set(False)
	bb1.set(False)
	cb_a = tk.Checkbutton(top, text='喜茶', variable=ab1, offvalue=False, onvalue=True)
	cb_a.pack()
	cb_b = tk.Checkbutton(top, text='蜜雪冰城', variable=bb1, offvalue=False, onvalue=True)
	cb_b.pack()
	s = 0
	if ab1.get() == True:
		s += 12.5
	if bb1.get() == True:
		s += 12.5
	if ab1.get() == False and bb1.get() == False:
		s -= 1
	return s

def q4():
	l4 = tk.Label(
		top,
		text='小学时，您喜欢？',
		font=('Arial', 12),
		width=30,
		height=2
	)
	l4.pack()
	ab2 = tk.BooleanVar()
	bb2 = tk.BooleanVar()
	ab2.set(False)
	bb2.set(False)
	cb_a = tk.Checkbutton(top, text='语文', variable=ab2, offvalue=False, onvalue=True)
	cb_a.pack()
	cb_b = tk.Checkbutton(top, text='英语', variable=bb2, offvalue=False, onvalue=True)
	cb_b.pack()
	s = 0
	if ab2.get() == True:
		s += 12.5
	if bb2.get() == True:
		s += 12.5
	if ab2.get() == False and bb2.get() == False:
		s -= 1
	return s

qlst = [q1, q2, q3, q4]
slst = []
all_q = True
for i in qlst:
	slst.append(i())

def OK():
	if -1 in slst:
		na = ''
		for i in range(len(qlst)):
			if qlst[i] == -1:
				na += str(i)
		tk.messagebox.showinfo('警告',f'{na}题未答完')
	else:
		print(sum(slst))
b = tk.Button(top, text='提交', command=OK)
b.pack()

top.mainloop()
